package com.itheima.d4_create_thread;

import org.slf4j.Logger;

import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;

/**
 * 目标：掌握线程的创建方式三：实现Callable接口。
 */
public class ThreadTest3 {

    public static void main(String[] args) throws Exception {
        final MyThread1 myThread1 = new MyThread1();
        final FutureTask<String> objectFutureTask = new FutureTask<>(myThread1);

        final Thread thread = new Thread(objectFutureTask);
        thread.start();

        System.out.println(objectFutureTask.get());


    }
}

class MyThread1 implements Callable<String>{

    @Override
    public String call() throws Exception {
        return "哈哈哈哈";
    }
}
